package com.wanganui.chat;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xtwang
 * @des AI聊天配置
 * @date 2025/2/11 上午9:39
 */
@Configuration
public class ChatConfig {
    @Bean
    public ChatClient chatClient(OllamaChatModel ollamaChatModel, RedisChatMemory redisChatMemory, MilvusVectorStore milvusVectorStore) {
        return ChatClient.builder(ollamaChatModel)
                .defaultSystem("你是一个RAG知识库问答机器人，致力于解决用户提出的问题，并给出详细的解决方案")
                .defaultAdvisors(new MessageChatMemoryAdvisor(redisChatMemory), new QuestionAnswerAdvisor(milvusVectorStore))
                .build();
    }

}
